package ru.braim.weather_app.models;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Entity
@Getter
public class Region {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @Setter
    private String name;

    @ManyToOne
    @Setter
    @JoinColumn(name = "account_id", nullable = false)
    private Account account;

    @ManyToMany(mappedBy = "regions")
    @Setter
    private List<RegionType> regionType;

    @OneToMany(mappedBy = "region", cascade = CascadeType.ALL)
    @Setter
    private List<Weather> weathers;

    private Double latitude1;
    private Double latitude2;

    private Double longitude1;
    private Double longitude2;

    @Setter
    private String parentRegion;

    public boolean setLatitude_1(Double latitude) {
        if (latitude == null) {
            return false;
        }
        this.latitude1 = latitude;
        return true;
    }

    public boolean setLongitude_1(Double longitude) {
        if (longitude == null) {
            return false;
        }
        this.longitude1 = longitude;
        return true;
    }

    public boolean setLatitude_2(Double latitude) {
        if (latitude == null) {
            return false;
        }
        this.latitude2 = latitude;
        return true;
    }

    public boolean setLongitude_2(Double longitude) {
        if (longitude == null) {
            return false;
        }
        this.longitude1 = longitude;
        return true;
    }

    public boolean setName(String name) {
        if (name == null) {
            return false;
        }
        this.name = name;
        return true;
    }


}
